<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<div id="projectWizard" class="wizard box tabbedBox no-border">
	<div class=" header">
		<ul class="steps">
			<li><a class="current" href="#wiz_basicInfo">基本信息</a>
			</li>
			<li><a href="#wiz_service">服务范围</a>
			</li>
			
		</ul>
	</div>
	<div style="padding:0" class="content tabbed">
		<div id="wiz_basicInfo">

			<form:form id="formProjectBasicInfo" commandName="model"
				action="project/project/save">
				<form:hidden path="id" />
				<table class="form-table">
					<tr>
						<td class="td1">项目名称：</td>
						<td class="td2" colspan="3"><form:input path="name"
								cssClass="required" style="width:78%" /></td>

					</tr>
				</table>
				<table class="form-table">

					<tr>


						<td class="td1">项目编号：</td>
						<td class="td2"><form:input path="code" disabled="true" /><span>
								(自动生成)</span>
						</td>
						<%-- <td class="td1">项目级别：</td>
						<td class="td2"><form:select path="projectLevel"
								cssClass="required" items="${projectLevels }" itemValue="name"
								itemLabel="name" />
						</td> --%>
					</tr>

					<tr>
						<td class="td1">项目类型：</td>
						<td class="td2"><form:select path="projectType"
								cssClass="required search" items="${projectTypes }"
								itemValue="name" itemLabel="name" /></td>
						<td class="td1">合同编号：</td>
						<td class="td2"><form:input path="contractNo" cssClass="" />
						</td>
					</tr>
					<tr>
						<td class="td1">项目经理：</td>
						<td class="td2"><form:hidden path="managerId" /> <isperp:departmentUser
								displayValue="${model.managerName }" valueControlId="managerId"
								id="managerName" name="managerName"
								displayValueCssClass="required"></isperp:departmentUser>
						</td>

						<td class="td1">销售：</td>
						<td class="td2"><form:hidden path="sellerId" /> <isperp:departmentUser
								displayValue="${model.sellerName }" valueControlId="sellerId"
								id="sellerName" name="sellerName"
								displayValueCssClass="required"></isperp:departmentUser></td>
					</tr>
					<tr>
						<td class="td1">项目起止日期：</td>
						<td class="td2"><form:input path="startDate" type="date"
								cssClass="required" style="width:75px" />~<form:input
								path="endDate" type="date" cssClass="required"
								style="width:75px" /></td>
						<td class="td1">项目状态：</td>
						<td class="td2"><form:input path="status" readonly="true" />
						</td>
					</tr>
					<tr>
						<td class="td1">项目金额：</td>
						<td class="td2"><c:choose>
								<c:when test="${model.status eq initStatus }">
									<form:input path="account" maxlength="12"
										cssStyle="width:100px" cssClass="number" />(元)
								</c:when>
								<c:otherwise>
									<form:input path="account" cssClass="number" readonly="true" />(元)
								</c:otherwise>

							</c:choose></td>
						<td class="td1">工作日历：</td>
						<td class="td2"><form:select path="appCalendarConfigId"
								items="${appCalendars }" itemLabel="name" itemValue="id"></form:select>
						</td>

					</tr>
					<!-- 
					<tr>
						<td class="td1">服务条款：</td>
						<td class="td2" colspan="3"><form:textarea
								path="serviceContent" />
						</td>
					</tr> -->
					<tr>
						<td class="td1">备注：</td>
						<td class="td2" colspan="3"><form:textarea path="memo" /> </textarea>
						</td>
					</tr>
				</table>
				<table class="form-table">
					<tr>
						<td class="td1">附件：
						<td class="td2" colspan="3">(附件包括本项目的招标文件、投标文件、合同等相关文档)<br />
							<isperp:uploader sourceId="${model.id }" id="projectFiles"></isperp:uploader>
						</td>
					</tr>
				</table>

				<table class="form-table">
					<tr>
						<td class="td1">客户名称：</td>
						<td class="td2"><form:hidden path="cusCustomerId" /> <isperp:listSelector
								id="customerSelector" url="customer/customer/list"
								displayValue="${model.cusCustomerName }" showPager="true"
								displayValueCssClass="required" valueControlId="cusCustomerId"
								name="cusCustomerName">
								<isperp:column name="id" title="id" hidden="true" width="10"></isperp:column>
								<isperp:column name="name" title="名称" width="150">
								</isperp:column>
								<isperp:column name="type" title="类型" width="80">
								</isperp:column>
								<isperp:column name="linkman" title="联系人" width="80">
								</isperp:column>
								<isperp:column name="linktel" title="联系电话" width="80">
								</isperp:column>

							</isperp:listSelector> <a class="nui-txt-link" href="javascript:openCreateCus(1);">
								创建客户 </a><a class="nui-txt-link" href="javascript:openCreateCus(0);">更新
						</a>
						</td>
						<td class="td1">邮箱：</td>
						<td class="td2"><form:input path="customerEmail" cssClass="" />
						</td>
					</tr>
					<tr>
						<td class="td1">联系人：</td>
						<td class="td2"><form:input path="customerLinkman"
								cssClass="" /></td>
						<td class="td1">联系电话：</td>
						<td class="td2"><form:input path="customerLinktel"
								cssClass="" /></td>
					</tr>
					<tr>

						<td class="td1">项目地址：</td>
						<td class="td2" colspan="3"><form:input path="projectAddress"
								style="width:78%" />
						</td>
					</tr>
				</table>
			</form:form>

			<isperp:datalog businessId="${model.id }"></isperp:datalog>

		</div>

		<div id="wiz_service">
			<div id="wiz_service_content"></div>
			<div style="width:98%;overflow: hidden">
				<h2>&nbsp;&nbsp;项目配置项描述（请填写详细的配置项内容）</h2>
				<form id="formConfDescription"
					action="project/project/updateConfDescription">
					<input type="hidden" name="projectId" value="${model.id }">
					<textarea id="projConfDescription" name="confDescription">${model.confDescription }</textarea>
				</form>
			</div>
		</div>
		
	</div>
	<isperp:wizButtonList buttonListId="bpmConfigWizardBtns"
		hiddenFinishButton="true">
		<isperp:processButtons processKey="projectProcess"
			processId="${model.processId }" businessKey="${model.id }"
			formId="formProjectBasicInfo"></isperp:processButtons>
	</isperp:wizButtonList>
</div>
<div id="createCusDialog" title="创建用户"
	style="display:none;padding:5px;-webkit-overflow-scrolling:touch; overflow:auto;">
	<iframe id="createCusIframe" src=""
		style="width:100%;height:100%;;border:none"></iframe>
</div>
<script type="text/javascript">
	var createCusUserDlg = $("#createCusDialog").dialog({
		modal : true,
		autoOpen : false,
		width : 500,
		height : 500,
		open : function(event, ui) {
			$("#createCusUserId").val("");
		},
		buttons : {
			保存 : function() {
				var $me = $(this);
				isperp.getWindow("createCusIframe").sumbitCusForm(function(id,name) {
					$("#cusCustomerId").val(id);
					$("#customerSelector").val(name);
					$me.dialog("close");					
				});
			}
		}
	});

	//新增客户
	function openCreateCus(isNew) {
		var title;
		if (isNew) {
			title = "创建";
			$("#createCusIframe").attr("src", "customer/customer/edit?hideBtn=true");
		} else {
			title = "更新";
			var cusCustomerId = $("#cusCustomerId").val();
			$("#createCusIframe").attr("src", "customer/customer/edit?hideBtn=true&id="+cusCustomerId);
		}

		createCusUserDlg.dialog({
			title : title
		});
		createCusUserDlg.dialog("open");

	}

	function submitForm(afterSuccess) {
		return isperp.submitForm({
			formId : "formProjectBasicInfo",
			success : function(data, textStatus, jqXHR) {

			}
		});
	}

	var projectWizard = isperp.wizard({
		wizardId : "projectWizard"
	});

	var projectWizard_Event0 = function(index, obj) {

	};

	var projectWizard_Event1 = function(index, obj) {
		var result = submitForm();
		if (result == false) {
			return false;
		}

		$("#wiz_service_content").empty().load("project/project/scopeOfService?projectId=${model.id}", function() {
			isperp.setEditor("projConfDescription");
		});

	};

	var projectWizard_Event2 = function(index, obj) {

		isperp.submitForm({
			formId : "formConfDescription",
			success : function(data, textStatus, jqXHR) {

			}
		});

		$("#wiz_member").empty().load("project/project/member?projectId=${model.id}");

	};

	var projectWizard_Event3 = function(index, obj) {
		$("#wiz_plan").empty().load("project/project/plan?projectId=${model.id}");
	};
</script>


<c:choose>
	<c:when test="${model.status eq initStatus }">
		<script type="text/javascript">
			var projectWizard_Event4 = function(index, obj) {
				$("#wiz_cost").empty().load("project/project/cost?projectId=${model.id}");
			};
			var projectWizard_Event5 = function(index, obj) {
				var costTemplateId = $("#projCostTemplateId").val();

				if (costTemplateId) {

					isperp.submitForm({
						formId : "formProjectCostItem",
						success : function(data, textStatus, jqXHR) {

						}
					});

				}

				$("#wiz_quality").empty().load("project/project/quality?projectId=${model.id}");
			};
		</script>
	</c:when>
	<c:otherwise>
		<script type="text/javascript">
			var projectWizard_Event4 = function(index, obj) {
				$("#wiz_cost").empty().load("project/project/cost?projectId=${model.id}&state=view");
			};

			var projectWizard_Event5 = function(index, obj) {
				$("#wiz_quality").empty().load("project/project/quality?projectId=${model.id}");
			}
		</script>
	</c:otherwise>


</c:choose>